package com.fh.util;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * Created by admin on 2017/6/3.
 */
public class PhoneUtil {

    private static String url = "https://tcc.taobao.com/cc/json/mobile_tel_segment.htm";
    //private static String url = DynamicConfigLoader.getByEnv("mobile_tel_address");

    public static Map<String ,String> getPhoneInfo(String phone){
        if (phone == null || "".equalsIgnoreCase(phone)) {
            return new HashMap<>();
        }
        if(!Pattern.matches("^1[0-9]{10}$" ,phone)){
            return new HashMap<>();
        }
        Map<String, String> param = new HashMap<String, String>();
        param.put("tel", phone);
        String json = HttpUtils.sendGetGBK(url, param);
        String replaceAll = json.replaceAll("^[__]\\w{14}+[_ = ]+","");

        Object parse = GsonUtil.fronJson2Map(replaceAll);

        Map<String, String> map = JacksonUtil.bean2Map1(parse);

        return map;
    }
}

	